package com.example.pattern.singleton;

/**
 * 双重检查锁定（线程安全）
 *
 * @author FM_南风
 * @date 2024/6/22
 */
public class SingletonC {
 private static volatile SingletonC instance;

 private SingletonC() {}

 public static SingletonC getInstance() {
  if (instance == null) {
   synchronized (SingletonC.class) {
    if (instance == null) {
     instance = new SingletonC();
    }
   }
  }
  return instance;
 }
}